package com.netted.operationassistant.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.animation.AlphaAnimation;

import com.blankj.utilcode.util.ObjectUtils;
import com.jude.rollviewpager.RollPagerView;
import com.netted.operationassistant.R;
import com.netted.operationassistant.adapter.ImageAdapter;
import com.netted.operationassistant.constant.Constant;
import com.netted.operationassistant.sharedPreferences.SharedPreferencesHelper;
public class MainActivity extends BaseActivity {

    String catbinetId = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        sharedPreferencesHelper = new SharedPreferencesHelper(this, Constant.XML_NAME);
    }




    @Override
    protected void onResume() {
        super.onResume();
        new Thread(new Runnable() {
            @Override
            public void run() {
                Object catbinetIdObj = sharedPreferencesHelper.getSharedPreference("id",null);
                if (ObjectUtils.isEmpty(catbinetIdObj)){
                    try {
                        Thread.sleep(2000);
                        Intent intent = new Intent(MainActivity.this,LoginActivity.class);
                        startActivity(intent);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }else{
                    try {
                        Thread.sleep(2000);
                        Intent intent = new Intent(MainActivity.this,MenuActivity.class);
                        startActivity(intent);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();



    }

    public void bgClick(View view){

        Intent intent = new Intent(this,MenuActivity.class);
        startActivity(intent);
    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
    }

    @Override
    protected void onUserLeaveHint() {
//        super.onUserLeaveHint();
    }

    @Override
    public void onOptionsMenuClosed(Menu menu) {
//        super.onOptionsMenuClosed(menu);
    }



    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode == KeyEvent.KEYCODE_BACK) { //监控/拦截/屏蔽返回键
            return true;
        } else if(keyCode == KeyEvent.KEYCODE_MENU) {//MENU键
            //监控/拦截菜单键
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
